home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / xulrunner / python / frontend_implementation / Application.py < prev    next >
Encoding:
Python Source  |  2007-11-12  |  4.1 KB  |  111 lines

  1. # Miro - an RSS based video player application
  2. # Copyright (C) 2005-2007 Participatory Culture Foundation
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  17.  
  18. import sys
  19. import frontend
  20. import time
  21. import resources
  22. import config
  23. import prefs
  24. import os
  25. import searchengines
  26. import views
  27. from platformutils import _getLocale as getLocale
  28.  
  29. from frontend_implementation import HTMLDisplay
  30. import migrateappname
  31.  
  32. ###############################################################################
  33. #### Application object                                                    ####
  34. ###############################################################################
  35. class Application:
  36.  
  37.     def __init__(self):
  38.         print "Application init"
  39.  
  40.     def Run(self):
  41.         HTMLDisplay.initTempDir()
  42.  
  43.         lang = getLocale()
  44.         if lang:
  45.             if not os.path.exists(resources.path(r"..\chrome\locale\%s" % (lang,))):
  46.                 lang = "en-US"
  47.         else:
  48.             lang = "en-US"
  49.  
  50.         from xpcom import components
  51.         ps_cls = components.classes["@mozilla.org/preferences-service;1"]
  52.         ps = ps_cls.getService(components.interfaces.nsIPrefService)
  53.         branch = ps.getBranch("general.useragent.")
  54.         branch.setCharPref("locale", lang)
  55.  
  56.         import psyco
  57.         #psyco.log('\\dtv.psyco')
  58.         psyco.profile(.03)
  59.  
  60.         # Start the core.
  61.         if frontend.startup.search:
  62.             self.onStartup(frontend.startup.search.getFiles())
  63.         else:
  64.             self.onStartup()
  65.         frontend.jsBridge.positionVolumeSlider(config.get(prefs.VOLUME_LEVEL))
  66.  
  67.     def onStartup(self):
  68.         # For overriding
  69.         pass
  70.  
  71.     def finishStartupSequence(self):
  72.         from xpcom import components
  73.         pybridge = components.classes["@participatoryculture.org/dtv/pybridge;1"].getService(components.interfaces.pcfIDTVPyBridge)
  74.         self.initializeSearchEngines()
  75.         migrateappname.migrateVideos('Democracy', 'Miro')
  76.         pybridge.updateTrayMenus()
  77.  
  78.     def initializeSearchEngines(self):
  79.         names = []
  80.         titles = []
  81.         for engine in views.searchEngines:
  82.             names.append(engine.name)
  83.             titles.append(engine.title)
  84.         frontend.jsBridge.setSearchEngineInfo(names, titles)
  85.         frontend.jsBridge.setSearchEngine(searchengines.getLastEngine())
  86.  
  87.     def onShutdown(self):
  88.         # For overriding
  89.         pass
  90.  
  91.     # This is called on OS X when we are handling a click on an RSS feed
  92.     # button for Safari. NEEDS: add code here to register as a RSS feed
  93.     # reader on Windows too. Just call this function when we're launched
  94.     # to handle a click on a feed.
  95.     def addAndSelectFeed(self, url):
  96.         # For overriding
  97.         pass
  98.  
  99.     def onUnwatchedItemsCountChange(self, obj, id):
  100.         from xpcom import components
  101.         pybridge = components.classes["@participatoryculture.org/dtv/pybridge;1"].getService(components.interfaces.pcfIDTVPyBridge)
  102.         pybridge.updateTrayMenus()
  103.  
  104.     def onDownloadingItemsCountChange(self, obj, id):
  105.         from xpcom import components
  106.         pybridge = components.classes["@participatoryculture.org/dtv/pybridge;1"].getService(components.interfaces.pcfIDTVPyBridge)
  107.         pybridge.updateTrayMenus()
  108.  
  109. ###############################################################################
  110. ###############################################################################
  111.